import * as React from 'react';
import {observer} from 'mobx-react'
import styles from './index.scss';
import {Carousel} from 'antd';

import error from '../../../../assets/imgs/test/error.png'
import waring from '../../../../assets/imgs/test/waring.png'
import {IEmergencyrType} from "../../../../type/firstType";
import ModalText from "../../../../components/ModalText";


interface IProps {
    borderBottom: string
    borderTop: string
    emergencyrList: IEmergencyrType[]
}

@observer
class Home extends React.Component<IProps> {

    constructor(props) {
        super(props);
    }


    public render() {
        const {borderBottom, borderTop, emergencyrList} = this.props
        return (
            <div className={styles.swiper} style={{borderBottom: borderBottom}}>
                <div className={styles.title} style={{borderTop: borderTop}}>
                    <span className={styles.spanWidth}><ModalText text='备件订单号' long={10} /></span>
                    <span className={styles.spanWidth}><ModalText text='备件订单列表' long={10} /></span>
                    <span className={styles.spanWidth}><ModalText text='始发地' long={10} /></span>
                    <span className={styles.spanWidth}><ModalText text='目的地' long={10} /></span>
                    <span className={styles.spanWidth}><ModalText text='事件描述' long={10} /></span>
                    <span className={styles.spanWidth}><ModalText text='操作时间' long={10} /></span>
                    <span className={styles.spanWidth}><ModalText text='操作地点' long={10} /></span>
                </div>
                <div className={styles.swiperC}>
                    {
                        emergencyrList.length > 0 &&
                        <Carousel autoplay={true} dots={false} vertical={true} slidesToShow={6} autoplaySpeed={2000}>
                            {
                                emergencyrList.map((item, index) => {
                                    return (
                                        <div className={index % 2 === 0 ? styles.list1 : styles.list} key={`itemLTBT_${index}`}>
                                            <img src={item.finished === 'critical' ? error : waring}
                                                 className={styles.error} />
                                            <div className={styles.listC}>
                                                <span className={styles.spanWidth}><ModalText text={item.PartsRequest}
                                                                                              long={10} /></span>
                                                <span className={styles.spanWidth}><ModalText text={item.waybillnumber}
                                                                                              long={10} /></span>
                                                <span className={styles.spanWidth}><ModalText text={item.origcity}
                                                                                              long={10} /></span>
                                                <span className={styles.spanWidth}><ModalText text={item.destcity}
                                                                                              long={10} /></span>
                                                <span className={styles.spanWidth}><ModalText
                                                    text={item.eventdescription} long={10} /></span>
                                                <span className={styles.spanWidth}><ModalText text={item.operatedate}
                                                                                              long={10} /></span>
                                                <span className={styles.spanWidth}><ModalText text={item.operateplace}
                                                                                              long={10} /></span>
                                            </div>
                                        </div>
                                    )
                                })
                            }
                        </Carousel>
                    }
                </div>
            </div>
        );
    }
}

export default Home;
